package TEC;

import javafx.scene.control.TextArea;

public class DrawLine {
    public void AddCharToLastLine(TextArea textArea, String content) {
        textArea.appendText(content);
    }

    public void RecCharAtLastLine(TextArea textArea) {
        textArea.deleteText(textArea.getLength() - 1, textArea.getLength());
    }

    public void newLine(TextArea textArea, String content) {
        textArea.appendText("\n" + content);
    }

    public void newLine(TextArea textArea, Integer PC) {
        textArea.appendText("\n" + addZore(Integer.toHexString(PC).length()) + Integer.toHexString(PC) + " : ");
    }

    public void newLine(TextArea textArea, Integer PC, String content) {
        textArea.appendText("\n" + addZore(Integer.toHexString(PC).length()) + Integer.toHexString(PC) + " : " + content);
    }

    private String addZore(int length) {
        String ret = "";
        int num = 4 - length;
        if (num > 0) {
            for (int i = 0; i < num; i++) {
                ret += "0";
            }
        }
        return ret;
    }

    public void Error(TextArea textArea) {
        textArea.appendText("\n\terror!");
    }
}
